<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button id="btn">按钮</button>
    <script src="./myAjax.js"></script>
    <script>
      btn.onclick = async function () {
        const promise = myAjax({
          url: 'http://localhost:5000/test',
          params: {
            x: 1,
            y: 2,
          },
          method: 'get',
        })
        // result可以接收到成功的promise的value属性值
        // 实际上就是响应主体的数据
        const result = await promise

        console.log(result)
      }
    </script>
  </body>
</html>
